#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    : 2023/11/28 23:16
# @function: the script is used to do something.
# @version : 


import requests
from lxml import etree

# 获取资源地址
for i in range(1, 11):
    url = 'https://www.77xsw.cc/fenlei/1_{}/'.format(i)
    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
    }
    # 发送请求 获取响应
    response = requests.get(url, headers=headers)
    response.encoding = 'gbk'
    # 提取数据
    html = etree.HTML(response.text)
    href_list = html.xpath('//span[@class="sp_2"]/a/@href')
    title_list = html.xpath('//span[@class="sp_2"]/a/text()')

    for href, title in zip(href_list, title_list):
        item = {}
        item['title'] = title
        item['href'] = href
        print(item)
